<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数字比较器 - 2025.3.31</title>
    <style>
        body {
            font-family: 'Microsoft YaHei', sans-serif;
            max-width: 500px;
            margin: 0 auto;
            padding: 20px;
            background-color: #f0f8ff;
        }
        h1 {
            color: #2e8b57;
            text-align: center;
            margin-bottom: 30px;
        }
        .container {
            background-color: white;
            padding: 25px;
            border-radius: 10px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        }
        .input-group {
            margin-bottom: 20px;
        }
        label {
            display: block;
            margin-bottom: 8px;
            font-weight: bold;
            color: #4682b4;
        }
        input[type="number"] {
            width: 100%;
            padding: 10px;
            border: 2px solid #add8e6;
            border-radius: 5px;
            box-sizing: border-box;
            font-size: 16px;
        }
        button {
            background-color: #4caf50;
            color: white;
            border: none;
            padding: 12px 0;
            border-radius: 5px;
            cursor: pointer;
            font-size: 18px;
            width: 100%;
            margin-top: 10px;
            transition: background-color 0.3s;
        }
        button:hover {
            background-color: #3e8e41;
        }
        .result {
            margin-top: 25px;
            padding: 20px;
            background-color: #e6f7e6;
            border-radius: 5px;
            border-left: 5px solid #2e8b57;
            display: none;
        }
        .error {
            color: #ff4500;
            margin-top: 15px;
            padding: 10px;
            background-color: #ffe6e6;
            border-radius: 5px;
            display: none;
        }
        .result h3 {
            color: #2e8b57;
            margin-top: 0;
        }
        .result p {
            font-size: 18px;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>数字大小比较器</h1>
        <div class="input-group">
            <label for="num1">第一个数字:</label>
            <input type="number" id="num1" placeholder="输入第一个数字">
        </div>
        <div class="input-group">
            <label for="num2">第二个数字:</label>
            <input type="number" id="num2" placeholder="输入第二个数字">
        </div>
        <div class="input-group">
            <label for="num3">第三个数字:</label>
            <input type="number" id="num3" placeholder="输入第三个数字">
        </div>
        <button onclick="compareNumbers()">比较并排序</button>
        <div id="error" class="error"></div>
        <div id="result" class="result"></div>
    </div>

    <script>
        function compareNumbers() {
            // 获取输入元素
            const num1Input = document.getElementById('num1');
            const num2Input = document.getElementById('num2');
            const num3Input = document.getElementById('num3');
            const errorElement = document.getElementById('error');
            const resultElement = document.getElementById('result');
            
            // 隐藏之前的结果和错误
            errorElement.style.display = 'none';
            resultElement.style.display = 'none';
            
            // 获取输入值
            const num1 = parseFloat(num1Input.value);
            const num2 = parseFloat(num2Input.value);
            const num3 = parseFloat(num3Input.value);
            
            // 验证输入
            if (isNaN(num1) || isNaN(num2) || isNaN(num3)) {
                errorElement.textContent = "错误：请确保三个输入框都输入了有效的数字！";
                errorElement.style.display = 'block';
                return;
            }
            
            // 将数字放入数组并排序
            const numbers = [num1, num2, num3];
            numbers.sort((a, b) => b - a); // 从大到小排序
            
            // 显示结果
            resultElement.innerHTML = `
                <h3>排序结果</h3>
                <p>从大到小的顺序是: ${numbers[0]} > ${numbers[1]} > ${numbers[2]}</p >
            `;
            resultElement.style.display = 'block';
        }
    </script>
</body>
</html>